﻿
    using Chain.BLL;
    using System;
    using System.Data;
    using System.IO;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;

    public partial class WeiXinPointExchange : Page
    {
        protected string MemWeiXinCard = string.Empty;

        private PointGift pointGiftBll = new PointGift();
        protected string rc = PubFunction.GetDataTimeString();


        private void BindData()
        {
            int count;
            string strWhere = string.Empty;
            if (PubFunction.curParameter.bolGiftShare)
            {
                strWhere = "PointGift.GiftClassID=GiftClass.GiftClassID and PointGift.GiftShopID=SysShop.ShopID";
            }
            else
            {
                strWhere = "PointGift.GiftClassID=GiftClass.GiftClassID and PointGift.GiftShopID=SysShop.ShopID and SysShop.ShopID=1";
            }
            DataTable dt = this.pointGiftBll.GetListSP(10, 1, false, out count, new string[] { strWhere }).Tables[0];
            if (dt.Rows.Count > 0)
            {
                this.Rpt_WeiXinPointExchange.DataSource = dt;
                this.Rpt_WeiXinPointExchange.DataBind();
            }
            else
            {
                this.noProduct.Style.Add("display", "\"\"");
            }
        }

        protected string GetPhoto(string Photo)
        {
            string text1 = "http://" + PubFunction.curParameter.strDoMain;
            string strPhoto = "http://" + PubFunction.curParameter.strDoMain + Photo;
            if (!File.Exists(base.Server.MapPath(Photo)))
            {
                return "/Upload/MemPhoto/nophoto.gif";
            }
            return strPhoto;
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            this.MemWeiXinCard = base.Request["MemWeiXinCard"];
            if (!string.IsNullOrEmpty(this.MemWeiXinCard))
            {
                this.BindData();
            }
        }

        protected void Rpt_WeiXinPointExchange_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if ((e.Item.ItemType == ListItemType.Item) || (e.Item.ItemType == ListItemType.AlternatingItem))
            {
                HtmlAnchor linkimg = (HtmlAnchor) e.Item.FindControl("linkimg");
                if (linkimg != null)
                {
                    linkimg.HRef = "WeiXinGiftShow.aspx?GiftID=" + linkimg.HRef + "&MemWeiXinCard=" + this.MemWeiXinCard;
                }
            }
        }
    }


